﻿using Microsoft.AspNetCore.Mvc;
using RAP.Framework.Libary.SqlDataService.Service;
using RAP.Web.Core.Server.Service;
using RAP.Web.Libary.Common.Model;
using RAP.Web.Libary.Controller;
using RAP.Web.Libary.Controller.Attributes;
using System.Threading.Tasks;

namespace RAP.Web.Core.Server.Controllers.UserInfo
{
    /// <summary>
    /// 用户信息控制器
    /// </summary>
    public class UserInfoController : APIControllerBase
    {
        public UserInfoService UserInfoService { get; set; }

        public ISqlDataService SqlDataService { get; set; }

        public UserInfoController ( UserInfoService userInfoService )
        {
            this.UserInfoService = userInfoService;
        }

        /// <summary>
        /// 用户退出登录
        /// </summary>
        /// <returns></returns>
        public async Task<object> Logout ()
        {
            return await this.UserInfoService.Logout( QueryParams as IAPIQueryParams );
        }

        /// <summary>
        /// 微信登录
        /// </summary>
        /// <returns></returns>
        public async Task<object> WXLogin ()
        {
            return await this.UserInfoService.WXLogin( QueryParams as IAPIQueryParams );
        }

        /// <summary>
        /// 查询用户的数据权限
        /// </summary>
        /// <returns></returns>
        [NeedSession]
        public async Task<object> HasDataPower ()
        {
            return await this.UserInfoService.HasDataPower( QueryParams as IAPIQueryParams );
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        [NeedSession]
        public async Task<object> SaveUserInfo ()
        {
            return await this.UserInfoService.SaveUserInfo( QueryParams );
        }
    }
}
